<script type="text/javascript">
    function auto_search(url_search)
    {
        var key_search = $("#key_search").val();
        $.ajax({
            type: "POST",
            url: "<?=base_url()?>"+url_search,
            data: {key_search:key_search,field_search:$("#field_search").val(),type:"ajax",category_image_id:$("#category_image_id").val()},
            cache: false,
            dataType: "html",
            success: function(data){
                $("#tbl_file_search").html(data);
            }
        });
    }
    function insert(file){
            $("#hinhanh", top.document).val(file);
            parent.$.fn.colorbox.close();
    }
</script>
<? $seg2 = $this->router->fetch_method();?>

<div class="media-upload-header">
    <ul id="menu">
        <li><a href="<?=base_url()?>mod_file_manager/image_manager_editor/index" <?if($seg2=='index'){echo ' class="current"';}?>><?=lang('library');?></a></li>
        <li><a href="<?=base_url()?>mod_file_manager/image_manager_editor/upload" <?if($seg2=='upload'){echo ' class="current"';}?>><?=lang('upload_file');?></a></li>
        <li>
            <div class="defaults">
                <p class="element">
                <label for="insert_width">Image Width:</label>
                <input type="text" value="0" name="insert_width" id="insert_width">

                <span>Left</span><input type="radio" value="left" name="insert_float">
                <span>Right</span><input type="radio" value="right" name="insert_float">
                <span>None</span><input type="radio" checked="checked" value="none" name="insert_float">
                </p>
            </div>         
        </li>
    </ul>
</div>
<div style="padding: 20px;">
    <div style="text-align: center;width: 100%;" class="image_search_bar">
        <select style="float:left;" name="category_image_id" id="category_image_id" onchange="auto_search('mod_file_manager/image_manager_editor/index');">
            <option value="">All</option>
            <?php foreach($list_category as $category){
                echo '<option value="'.$category->image_category_id.'">'.$category->image_category_name.'</option>';
            }?>
        </select>
        <?php echo $search_bar;?>
    </div>
    <div id="tbl_file_search">
        <ul class="list_img">
            <?foreach($list as $rs):?>
                <li>
                    <div>
                        <img onclick="javascript:insertImage('<?=base_url_site().'uploads/images/'.$rs->lb_dir.'/'.$rs->lb_name?>','<?=$rs->lb_name?>')" src="<?=base_url_site().'uploads/images/'.$rs->lb_dir.'/'.$rs->lb_name?>" alt="" class="vnit_img" title="<?=lang('choose_file');?>">
                    </div>
                    <div class="title"><?=$rs->lb_name?></div>
                </li>    
            <?endforeach;?>
        </ul>
        <div class="clear"></div>
        <div class="pages"><?=$pagination?></div>
    </div>
</div>

